#include<iostream>
#include<vector>
using namespace std;
vector<int>path;
int sum=0;
void dfs(vector<int>&nums,int pos)
{
	int ret=0;
    int tmp=0;
     if(pos==nums.size())
    {
        
        for(auto x:path)
        {
            tmp^=x;
            //cout<<x<<" ";
        }
        cout<<tmp<<" ";
        cout<<endl;
        sum+=tmp;
        return;
    }
    
    for(auto x:path)
    {
        tmp^=x;
        //cout<<x<<" ";
    }
    
    tmp^=nums[pos];
    cout<<tmp<<" ";
    cout<<endl;
    sum+=tmp;
	
    for(int i=pos;i<nums.size();i++)
    {
        
        path.push_back(nums[i]);
        dfs(nums,i+1);
        path.pop_back();
    }
    
}

    int subsetXORSum(vector<int>& nums) {
         dfs(nums,0);
         return sum;
    } 
    int main()
    {
    	vector<int> nums={5,1,6};
    	cout<<subsetXORSum(nums);
    }
